package interfaces;

import org.newdawn.slick.Input;

public class StateController {
	public final static boolean on=true, off=false;
	int delay=0,curTime=delay;
	public boolean key_1=off,key_2=off,key_3=off,key_4=off,key_5=off;
	public boolean key_6=off,key_7=off,key_8=off,key_9=off,key_0=off;
	public boolean key_lShift=off, key_rShift=off, key_esc=off;
	public boolean key_Space=off,key_Up=off,key_Down=off,key_Left=off,key_Right=off;
	
	public boolean toggleNumbers=on, toggleFunctions=on, toggleController=off;
	
	public void disable(){toggleNumbers=off; toggleFunctions=off; toggleController=off;}
	public void enable(){toggleNumbers=on; toggleFunctions=on; toggleController=on;}
	public void toggle(){toggleNumbers=!toggleNumbers; toggleFunctions=!toggleFunctions; toggleController=!toggleController;}
	public void setDelay(int d){delay=d;}
	
	
	public void update(Input input, int delta){
		curTime+=delta;
		
		if(input.isKeyDown(Input.KEY_1) && curTime>delay && toggleNumbers){
			key_1=!key_1; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_2) && curTime>delay && toggleNumbers){
			key_2=!key_2; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_3) && curTime>delay && toggleNumbers){
			key_3=!key_3; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_4) && curTime>delay && toggleNumbers){
			key_4=!key_4; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_5) && curTime>delay && toggleNumbers){
			key_5=!key_5; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_6) && curTime>delay && toggleNumbers){
			key_6=!key_6; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_7) && curTime>delay && toggleNumbers){
			key_7=!key_7; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_8) && curTime>delay && toggleNumbers){
			key_8=!key_8; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_9) && curTime>delay && toggleNumbers){
			key_9=!key_9; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_0) && curTime>delay && toggleNumbers){
			key_0=!key_0; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_LSHIFT) && curTime>delay && toggleFunctions){
			key_lShift=!key_lShift; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_RSHIFT) && curTime>delay && toggleFunctions){
			key_rShift=!key_rShift; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_ESCAPE) && curTime>delay && toggleFunctions){
			key_esc=!key_esc; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_SPACE) && curTime>delay && toggleController){
			key_Space=!key_Space; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_UP) && curTime>delay && toggleController){
			key_Up=!key_Up; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_DOWN) && curTime>delay && toggleController){
			key_Down=!key_Down; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_LEFT) && curTime>delay && toggleController){
			key_Left=!key_Left; curTime=0;
		}
		
		if(input.isKeyDown(Input.KEY_RIGHT) && curTime>delay && toggleController){
			key_Right=!key_Right; curTime=0;
		}
		
	}
	
	
}
